<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>发布微博</h1>
    <input type="text" placeholder="说点什么呢..." v-model="content">
    <input type="button" value="发布" @click="insert()">
</div>

<!--引入Vue框架-->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el: "div",
        data: {
            content:""
        },
        methods: {
            insert(){
                axios.get("/insert?content="+v.content).then(function (response) {
                    if (response.data==1){
                        alert("发布完成!");
                        location.href="/";//回到首页
                    }else{
                        alert("请先登录!")
                        location.href="/login.html";
                    }
                })
            }
        }
    })
</script>
</body>
</html>